//
//  WeatherView.swift
//  Community
//
//  Created by JKSD on 2019/7/29.
//  Copyright © 2019 ZKJ. All rights reserved.
//

import UIKit

class WeatherView: UIView {
    let weakLab = UILabel()
    let imageView = UIImageView ()
    let temLab = UILabel()
    var min = "";
    var max = "";
    override init(frame: CGRect) {
        super .init(frame: frame)
        weakLab.frame = CGRect (x: 0, y: 0, width: frame.size.width, height: 20)
        weakLab.textColor = UIColor.white
        weakLab.font = constant.kFontSize(x: 10)
        weakLab.textAlignment = NSTextAlignment.center
        self.addSubview(weakLab)
        
        imageView.frame = CGRect (x: (frame.size.width - 40)/2.0, y: weakLab.n_maxY + 10, width: 40, height: 40)
        imageView.contentMode = UIView.ContentMode.scaleAspectFit
        self.addSubview(imageView)
        temLab.frame = CGRect (x: 0, y: imageView.n_maxY + 10, width: frame.size.width, height: 20)
        temLab.textColor = UIColor.white
        temLab.textAlignment = NSTextAlignment.center
        temLab.font = constant.kFontSize(x: 10)
        self.addSubview(temLab)
        weakLab.text = "周一"
        imageView.image = UIImage.init(named: "1184166")
        self.temLab.text = "26/30"
    }
    public func fillView(model:weatherModel) {
        weakLab.text =  model.day
        self.temLab.text = model.tem2 + "/" + model.tem1
       
        
        if model.wea.contains("雨"){
            imageView.image = UIImage.init(named: "1184220")
        }
        if model.wea.contains("云"){
            imageView.image = UIImage.init(named: "1184166")
        }
        if model.wea.contains("阴"){
            imageView.image = UIImage.init(named: "1184166")
        }
        if model.wea.contains("晴"){
            imageView.image = UIImage.init(named: "1184185")
        }
        if model.wea.contains("雪"){
            imageView.image = UIImage.init(named: "1184211")
        }
        if model.wea.contains("雷"){
            imageView.image = UIImage.init(named: "1184239")
        }
      
        
       
        
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
